#include <iostream>
#include <Windows.h>  // 必须包含 Windows API 头文件
#include <nlohmann/json.hpp>
#include <map>
using json = nlohmann::json;
using ordered_json = nlohmann::ordered_json;
using namespace std;

ordered_json sort_json_by_value(const ordered_json& j, const string& sortedKey) {
    // 提取键值对到 vector
    std::vector<std::pair<std::string, ordered_json>> items;
    for (const auto& item : j.items()) {
        items.emplace_back(item.key(), item.value());
    }

    // 按值排序，假设值为数值类型
    std::sort(items.begin(), items.end(),
              [](const auto& a, const auto& b) { return a.second < b.second; });

    // 创建新的 ordered_json 并按排序顺序插入
    ordered_json sorted_j;
    for (const auto& item : items) {
        sorted_j[item.first] = item.second;
    }

    return sorted_j;
}

int main()
{
    /* 临时生效：chcp 修改的代码页仅对当前控制台窗口有效。若程序启动新的控制台进程（如 system("新命令")），需要重新设置。*/
    // system("chcp 65001 > nul");

    /* 替代方案：对于更可靠的 Unicode 支持，可考虑直接使用 Windows API（如 SetConsoleOutputCP(65001)）而非 system 命令。 */
    SetConsoleOutputCP(65001); // 设置输出编码为 UTF-8

    // swimming ability 水性
    enum class SA {
    };
    // highly aqutic 高度水栖
    map<string, string> saMap;
    saMap["HA"] = "高度水栖";

    // Degree of Easy Maitenance 易养程度
    // suitable for beginners 适合新手
    map<string, string> demMap;
    demMap["SB"] = "适合新手";

    json turtleJson;
    turtleJson["巴西龟"] = {{"价格", 3}, {"水性", ""}, {"饲养难度", demMap["SB"]}};
    turtleJson["草龟"] = {{"价格", 5}};
    turtleJson["地图龟"] = {{"价格", 10}};
    turtleJson["拟鳄龟"] = {{"价格", 30}};
    turtleJson["麝香龟"] = {{"价格", 60}};
    turtleJson["日本石龟"] = {{"价格", 50}};
    turtleJson["黑池龟"] = {{"价格", 30}};
    turtleJson["剃刀龟"] = {{"价格", 200}};
    turtleJson["安布龟"] = {{"价格", 100}};
    turtleJson["钻纹龟"] = {{"价格", 300}};
    turtleJson["果核龟"] = {{"价格", 300}};
    turtleJson["鹰嘴龟"] = {{"价格", 500}};
    turtleJson["花龟"] = {{"价格", 5}};
    turtleJson["黄耳龟"] = {{"价格", 8}};
    turtleJson["黄喉龟"] = {{"价格", 20}};
    turtleJson["火焰龟"] = {{"价格", 20}};
    turtleJson["圆澳龟"] = {{"价格", 30}};
    turtleJson["西非龟"] = {{"价格", 150}};
    turtleJson["东锦龟"] = {{"价格", 40}};
    turtleJson["西锦龟"] = {{"价格", 20}};
    turtleJson["南锦龟"] = {{"价格", 130}};
    turtleJson["头盔龟"] = {{"价格", 180}};
    turtleJson["沼泽龟"] = {{"价格", 150}};
    turtleJson["黄缘龟"] = {{"价格", 400}};
    turtleJson["甜甜圈"] = {{"价格", 15}};
    turtleJson["红面龟"] = {{"价格", 100}};
    turtleJson["亚巨龟"] = {{"价格", 100}};
    turtleJson["猪鼻龟"] = {{"价格", 500}};
    turtleJson["玛塔龟"] = {{"价格", 500}};
    turtleJson["白唇蛋龟"] = {{"价格", 200}};
    turtleJson["锯缘龟"] = {{"价格", 300}};
    turtleJson["真鳄龟"] = {{"价格", 500}};
    turtleJson["眼斑龟"] = {{"价格", 700}};
    turtleJson["星点龟"] = {{"价格", 2800}};
    turtleJson["斑纹龟"] = {{"价格", 1600}};
    turtleJson["萨尔文龟"] = {{"价格", 2500}};
    turtleJson["窄桥龟"] = {{"价格", 2500}};
    turtleJson["墨西哥蛋龟"] = {{"价格", 850}};
    turtleJson["巨头蛋龟"] = {{"价格", 1300}};
    turtleJson["虎纹蛋龟"] = {{"价格", 1600}};
    turtleJson["长颈龟"] = {{"价格", 330}};



    std::cout << turtleJson.dump(2);

    return 0;
}
